//
//  YWNavigationController.m
//  maintain
//
//  Created by 郑想 on 15/10/9.
//  Copyright (c) 2015年 ewin. All rights reserved.
//

#import "YWNavigationController.h"
#import "UIColor+CustomColors.h"
#import "YWMacro.h"
#import "YWResourceManager.h"

@interface YWNavigationController ()

@end

@implementation YWNavigationController

+ (void)initialize
{
    UINavigationBar* navigationBar = [UINavigationBar appearance];
    //导航栏toolBar隐藏开关
    
    [navigationBar setTranslucent:NO];
    // 导航条颜色
    [navigationBar setBarTintColor:[UIColor colorWithHex:@"353d40"]];
    [navigationBar setTintColor:[UIColor whiteColor]];
    // 导航条背景透明
    [navigationBar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];
    [navigationBar setShadowImage:[[UIImage alloc] init]];

    NSMutableDictionary* titleAttrs = [NSMutableDictionary dictionary];
    titleAttrs[NSForegroundColorAttributeName] = [UIColor whiteColor];
    titleAttrs[NSFontAttributeName] = [UIFont boldSystemFontOfSize:18];
    [navigationBar setTitleTextAttributes:titleAttrs];

    UIBarButtonItem* item = [UIBarButtonItem appearance];
    NSMutableDictionary* textAttrs = [NSMutableDictionary dictionary];
    textAttrs[NSFontAttributeName] = [UIFont systemFontOfSize:15];
    [item setTitleTextAttributes:textAttrs forState:UIControlStateNormal];
}

- (BOOL)isToolbarHidden{
    return YES;
}

- (UIStatusBarStyle)preferredStatusBarStyle
{
    return UIStatusBarStyleLightContent;
}

- (void)pushViewController:(UIViewController*)viewController animated:(BOOL)animated{
    if (self.viewControllers.count > 0) {
        viewController.hidesBottomBarWhenPushed = YES;
    }
    [super pushViewController:viewController animated:animated];
}

- (UIViewController *)popViewControllerAnimated:(BOOL)animated{
    UIView *view = [self.view viewWithTag:kMBProgressHUDTag];
    if (view) {
        [view removeFromSuperview];
        view = nil;
    }
    UIViewController* viewController = [super popViewControllerAnimated:animated];
    return viewController;
}
@end
